extends Node

var astar = AStar2D.new()
var used_cells = []
var path : Array = []

func clear():
	astar.clear()
	
func _connect_points():
	for cell in used_cells:
		for neighbor in Config.neighbors:
			var next_cell = cell + neighbor
			if used_cells.has(next_cell):
				astar.connect_points(Config.id(cell),Config.id(next_cell),false)
				
#将移动点入库
func _add_points():
	for cell in used_cells:
		astar.add_point(Config.id(cell),cell,1)

func _get_path(start:Vector2,end:Vector2) -> Array:
	path = astar.get_point_path(Config.id(start),Config.id(end))
	path.remove(0)
	return path
